package cn.whitecao.contentcenter.hello;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author ：腼腆的老黄.
 * @date ：Created in 2019-10-10 20:37
 */
@Component
public class MyApplicationContext implements ApplicationContextAware, BeanFactoryAware {

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println(applicationContext);
        Map<String, Object> map = applicationContext.getBeansWithAnnotation(Service.class);
        System.out.println();
    }
    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println();
        beanFactory.getBean("shareService");
    }
}
